package com.xiyi_design.printer_manage.pub;

public class Result {
    private static final String SUCCESS = "操作成功";
    private static final String FAILURE = "操作失败";
    private int code;
    private String msg;
    private Object con;

    public Result(int code, String msg) {
        this(code, msg, null);
    }

    public Result(int code, String msg, Object con) {
        this.code = code;
        this.msg = msg;
        this.con = con;
    }

    public static Result succeed() {
        return new Result(200, SUCCESS);
    }

    public static Result succeed(Object con) {
        return new Result(200, SUCCESS, con);
    }

    public static Result succeed(String msg, Object con) {
        return new Result(200, msg, con);
    }

    public static Result succeed(int code, String msg, Object con) {
        return new Result(code, msg, con);
    }

    public static Result fail() {
        return new Result(500, FAILURE);
    }

    public static Result fail(int code, String msg) {
        return new Result(code, msg);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getCon() {
        return con;
    }

    public void setCon(Object con) {
        this.con = con;
    }

    @Override
    public String toString() {
        return "Result [code=" + code + ", msg=" + msg + ", con=" + con + "]";
    }
}
